<?php
declare (strict_types = 1);

namespace app\admin\controller;

use addons\Builder\facade\Builder;
//该文件为自动生成，请按需修改
class MakeOrder extends Base
{
    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\MakeOrder';
    //关联模型
    protected $hasOne = ['user'];

    public function index(): string
    {
        return Builder::Table()
        ->addColumn(['type' => 'checkbox', 'fixed' => 'left', 'title' => '全选'])
        ->addColumn(['field' => 'id', 'title' => '订单ID', 'width' => 90])
        ->addColumn(['field' => 'title', 'title' => '服务项目', 'width' => 150])
        ->addColumn(['field' => 'money', 'title' => '服务项目金额', 'width' => 150])
        ->addColumn(['field' => 'sn', 'title' => '订单编号', 'width' => 170])
        ->addColumn(['field' => 'code', 'title' => '预约会员', 'templet' => '#_userTpl', 'width' => 200])
        ->addColumn(['field' => 'create_time', 'title' => '下单时间', 'width' => 150])
        ->addColumn(['field' => 'name', 'title' => '姓名', 'width' => 150])
        ->addColumn(['field' => 'phone', 'title' => '手机号', 'width' => 100])
        ->addColumn(['field' => 'start_address', 'title' => '起始地', 'width' => 150])
        ->addColumn(['field' => 'end_address', 'title' => '目的地', 'width' => 120])
        ->addColumn(['field' => 'my_address', 'title' => '我的位置', 'width' => 120])
        ->addColumn(['field' => 'make_time', 'title' => '预约时间', 'width' => 150])
        ->addColumn(['field' => 'car_type', 'title' => '车辆类型','templet' => '#carTypeTpl', 'width' => 150])
        ->addColumn(['field' => 'case_img', 'title' => '病例图片','templet' => '#caseImgTpl', 'width' => 150])
        ->addColumn(['field' => 'status', 'title' => '订单状态', 'width' => 150])
        ->addColumn(['field' => 'type', 'title' => '服务类型', 'width' => 150])
        ->addColumn(['fixed' => 'right', 'align' => 'center', 'toolbar' => '#barDemo', 'title' => '操作', 'width' => 200])
        ->addTopButtons(['deleteAll', 'export'])
        ->addSearch([
            ['uid', '会员编号/昵称/手机号', 'input', '', '\app\common\model\User', 'code|nickname|mobile,id'],
            ['sn', '订单编号', 'input'],
            ['status', '订单状态', 'select', $this->model::getOrderStatus('', 2)],
            ['type', '服务类型', 'select', $this->model::getType('',2)],
        ])
        ->addRightButtons([
            'delete',
        ])
        ->fetch();
    }
}
